#ifndef D_MATH_H
#define D_MATH_H

namespace d_Math
{
	
	typedef class d_Vec2f;
	typedef class d_Vec3f;
	typedef class d_Vec4f;
	typedef class d_Vecf;
	typedef class d_Mat4f;
	typedef class d_Mat3f;
	typedef class d_Matf;
	typedef class d_Plane;
	

    	typedef unsigned int uint32;
	//#define in(a) ((uint32&) a)
	bool checkPointInTriangle(d_Vec3f point, d_Vec3f pa, d_Vec3f pb, d_Vec3f pc);
	d_Vecf solve_tridiagonal_system(d_Matf mat, d_Vecf b);
	d_Vecf solve_system_sor(d_Matf mat, d_Vecf b, float w);
	d_Vecf solve_system_cg(d_Matf A, d_Vecf b);

   	float len(const d_Vec3f a);
	float len(const d_Vec4f a);
    	d_Vec3f norm(const d_Vec3f a);
	float dot(const d_Vec3f a, const d_Vec3f b);
	float dot(const d_Vec4f a, const d_Vec4f b);
	d_Vec3f cross(const d_Vec3f a, const d_Vec3f b);
	d_Vec4f cross(const d_Vec4f &a, const d_Vec4f &b, const d_Vec4f &c);

	void gen_pascal(d_Matf& A);
	void house(d_Vecf& x, d_Vecf& v, double& b);
	void QR(d_Matf& A);
	bool equal_to_zero(float x);

	d_Mat4f HScale4f(d_Vec3f x);
	d_Mat4f HScale4f(float x, float y, float z);
	d_Mat4f HRot4f(d_Vec3f v, float a);
	d_Mat4f HXRot4f(float a);
	d_Mat4f HYRot4f(float a);
	d_Mat4f HZRot4f(float a);
	d_Mat4f HTrans4f(d_Vec3f t);

	d_Mat3f inv(const d_Mat3f &m);
	d_Mat3f adj(const d_Mat3f &m);
	d_Mat3f trans(const d_Mat3f &m);

	d_Mat4f inv(const d_Mat4f &m);
	d_Mat4f adj(const d_Mat4f &m);
	d_Mat4f trans(const d_Mat4f &m);
}

	#include "d_Vec3f.h"
	#include "d_Vec4f.h"
	#include "d_Vecf.h"
	#include "d_Mat4f.h"
	#include "d_Mat3f.h"
	#include "d_Matf.h"
	#include "d_Vec2f.h"
	#include "d_Plane.h"
	#include "d_MatFuncs.h"
  
#endif
